#ifndef Slider_First
#define Slider_First
#ifdef __GNUG__
#pragma interface
#endif

#include "CompVObject.h"

class Thumb;

enum SliderPartCodes {
	eSliderPageUpLeft   = 1,
	eSliderPageDownRight= 2,
	eSliderThumb        = 3
};

//---- Slider ------------------------------------------------------------------

class Slider: public CompositeVObject {
public:
	MetaDef(Slider);
	Slider(int id= cIdNone, Direction dir= eVert, bool fb= FALSE);

	void Update(bool redraw= TRUE);
	Command *DoLeftButtonDownCommand(Point, Token, int);
	void SetVal(const Point&, bool redraw= FALSE);
	Point GetVal();
	void SetMax(const Point&, bool redraw= FALSE);
	Point GetMax();
	void SetMin(const Point&, bool redraw= FALSE);
	Point GetMin();
	void SetThumbRange(const Point&, bool redraw= FALSE);
	Point GetThumbRange();
	void MoveThumb(const Point&);
	int Where(const Point&);

protected:
	virtual Thumb *MakeThumb();
	void SetContainer(VObject *v);
	Metric GetMinSize();
	GrCursor GetCursor(Point);
	void Draw(Rectangle);
	void SetOrigin(Point);

protected:
	Thumb *thumb;
	Direction dir;
	bool feedback;
	Point minVal, maxVal, currVal, bubbleSize;
};

inline Point Slider::GetVal()
	{ return currVal; }
inline Point Slider::GetMax()
	{ return maxVal; }
inline Point Slider::GetMin()
	{ return minVal; }
inline Point Slider::GetThumbRange()
	{ return bubbleSize; }

//---- Thumb -------------------------------------------------------------------

class Thumb: public VObject {
public:
	MetaDef(Thumb);
	Thumb(Slider *sl, Direction d);
	void Draw(Rectangle r);
	Metric GetMinSize();
	Command *DoLeftButtonDownCommand(Point, Token, int);
	GrCursor GetCursor(Point);

protected:
	Slider *slider;
	Direction dir;
};

//---- PagerCommand ------------------------------------------------------------

class PagerCommand: public Command {
public:
	PagerCommand(Slider *s, int p);
	void TrackFeedback(Point, Point, bool);
	Command *TrackMouse(TrackPhase, Point, Point, Point);

protected:
	Slider *slider;
	int part;
};

#endif

